package com.suixun.test;

public class JiGuangPush {
	/*public void JiGuangPush(List<String> telephones, String title, String content,
            boolean apnsProduction, boolean isOnlyAndroid,Long validTime ,JPushClient jpushClient,
            String timingpic) {

    	if(validTime==null){
    		validTime=86400L;
    	}
        Date now = new Date();
        int nowHours = now.getHours();
        PushPayload payload = null;

        Map<String, String> extras = new HashMap<String, String>();
        if (title == null) title = "";
        if (content == null) content = "";
        extras.put("title", title);
        extras.put("content", content);
        //考勤图片
        extras.put("timingpic", timingpic);

        // 设置消息通知IOS
        PlatformNotification iosNotification =
                IosNotification.newBuilder().setBadge(1).setAlert(content).setSound("sound.caf")
                        .addExtras(extras).build();
        // 在上午9点到下午9点IOS推送的消息，带声音;其他时间消息静音
        if (!(nowHours >= 9 && nowHours <= 21))
            iosNotification =
                    IosNotification.newBuilder().autoBadge().setAlert(content).addExtras(extras)
                            .build();

        Notification notification =
                Notification.newBuilder()
                        .addPlatformNotification(iosNotification)
                        // ios推送弹窗
                        .addPlatformNotification(
                                AndroidNotification.newBuilder().setAlert("").addExtras(extras)
                                        .build())// android推送
                        .build();

        Platform platform = Platform.android_ios();// 推送设备 为ios根android
        if (isOnlyAndroid) {
            platform = Platform.android();// 推送设备仅仅为android
            notification =
                    Notification
                            .newBuilder()
                            .addPlatformNotification(
                                    AndroidNotification.newBuilder().setAlert("").addExtras(extras)
                                            .build())// android推送
                            .build();
        }
        payload =
                PushPayload
                        .newBuilder()
                        .setNotification(notification)
                        .setPlatform(platform)
                        .setOptions(
                                Options.newBuilder().setApnsProduction(apnsProduction)
                                        .setTimeToLive(validTime).build())// 推送附加选项
                                                                      // ApnsProduction=false测试环境
                                                                      // 用户不在线时86400秒内上线后，继续推送
                        .setAudience(Audience.alias(telephones))// 推送目标
                        .build();

        try {
            PushResult result = jpushClient.sendPush(payload);
            // System.out.println(result);
        } catch (APIConnectionException e) {
            logger.error("Connection error, should retry later", e);
            // e.printStackTrace();
        } catch (APIRequestException e) {
            //logger.error("Should review the error, and fix the request", e);
            //logger.info("HTTP Status: " + e.getStatus());
            //logger.info("Error Code: " + e.getErrorCode());
            //logger.info("Error Message: " + e.getErrorMessage());
            // e.printStackTrace();
        }
    }*/
}
